-
-
Notifications
You must be signed in to change notification settings - Fork 142
feat(cryptography): introduce cryptography component #1346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a355188 to
441fe92
Compare
brendt
requested changes
Jul 29, 2025
Member
brendt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo after this is merged:
- Mention in the docs that this is an experimental package
brendt
approved these changes
Jul 30, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a new package,
tempest/cryptography. It contains utilities to work with hashing, signing and encrypting. Later, we may add support for other cryptography-related features, though the three major ones are implemented.Signing key
Note that after this pull request, we should encourage adding a
SIGNING_KEYenvironment variable to.envfiles. However, no exception would be triggered unless theSignerorEncrypterare resolved from the container without it. Currently, nothing use them.I thus added a familiar command
key:generate. This generates a key using the currently-configured algorithm (AES_256_GCMby default) and adds it to.env(or updates it if it already exists).Password hasher
The
PasswordHasherinterface is used to hash and verify passwords. The provided implementation can use either Argon2id or bcrypt, the former being the default.Signing
The
Signerinterface may be used to sign some data using a signing key, which would be configured globally. It could also verify the integrity of some data using a provided signature against the globally-configured key.Under the hood, the provided implementation uses PHP's
hmacfunctions and a newTimelockclass for preventing against timing attacks.Encrypting
The
Encrypterinterface uses OpenSSL to encrypt and decrypt data, usually with the same key as the signing key. Under the hood, it also verifies the authenticity of the decrypted data using the signer.Timelock
This is a class inspired by Laravel's
Timebox. It works exactly the same, except it usestempest/clockunder the hood.